public class Demo3 {
    public static void main(String[] args) {
        int[]arr={7,1,9,12,6,2};
        for (int i = 1; i <arr.length ; i++) {
            int tmp=arr[i];
            int j = i-1;
            for (; j >=0; j--) {
                if(arr[j]>tmp){
                    arr[j+1]=arr[j];
                }else{
                    arr[j+1]=tmp;
                    break;
                }
            }
            arr[j+1]=tmp;
        }
    }
}
